package org.durandj.ystream.server.network.packetHandlers;

import java.nio.ByteBuffer;

import org.durandj.ystream.server.Server;
import org.durandj.ystream.server.message.Message;
import org.durandj.ystream.server.message.MessageID;
import org.durandj.ystream.server.network.Packet;
import org.durandj.ystream.server.network.PacketHandler;
import org.durandj.ystream.server.util.ByteBufferUtils;

/**
 * Handles the disconnect packets from the client.
 * 
 * @author durandj
 * @version 1.0
 *
 */
public class ServerDisconnectPacketHandler extends PacketHandler
{
	/**
	 * Creates a packet handler for client disconnects.
	 */
	public ServerDisconnectPacketHandler()
	{
		super();
	}

	/* (non-Javadoc)
	 * @see org.durandj.ystream.server.network.PacketHandler#handlePacket(org.durandj.ystream.server.network.Packet)
	 */
	@Override
	protected void handlePacket(Packet packet)
	{
		ByteBuffer buf = ByteBufferUtils.stringToByteBuffer(packet.getSource());
		Server.getServer().getClientManager().queueMessage(new Message(Message.Priority.MEDIUM, MessageID.DISCONNECT_CLIENT, this, buf));
	}
}
